package cn.hnbjx.prepaid.controller;

import cn.hnbjx.prepaid.pojo.RescueUser;
import cn.hnbjx.prepaid.service.RescueUserService;
import cn.hnbjx.prepaid.service.UserHelpService;
import cn.hnbjx.prepaid.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController

public class RescueUserController {
    @Autowired
    private RescueUserService rescueUserService;
    @Autowired
    private  UserHelpService userHelpService;
    @GetMapping("/admin/rescueUser/list")
    public Result list(int page,String key) {
        return Result.ok(rescueUserService.findAll(page,key));
    }
    @GetMapping("/api/rescueUser/list")
    public Result list(int page,int type,int id) {
        return Result.ok(rescueUserService.apifindAll(page,type,id));
    }

    @GetMapping("/api/rescueUser/add")
    public Result add(Integer rescue_user_id,Integer user_id,Integer user_help_id,Integer flag,String city) {
        RescueUser rescueUser = new RescueUser();
        rescueUser.setRescueUserId(rescue_user_id);
        rescueUser.setUserId(user_id);
        rescueUser.setUserHelpId(user_help_id);
        rescueUser.setFlag(flag);
        rescueUser.setCity(city);
        rescueUserService.insert(rescueUser);

        userHelpService.updateFlag(flag,user_help_id);
        return Result.ok("操作成功");
    }

}
